package com.dunqi.gpm.cangxi.WeekReport.WeekChek

import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.chad.library.adapter.base.BaseViewHolder

import com.dunqi.gpm.cangxi.R
import com.dunqi.gpm.cangxi.WeekReport.Model.WeekChekModel
import com.dunqi.gpm.cangxi.WeekReport.OnListFragmentInteractionListener
import com.dunqi.gpm.cangxi.common.base.RecyclerAdapter

/**
 * [RecyclerView.Adapter] that can display a [DummyItem] and makes a call to the
 * specified [OnListFragmentInteractionListener].
 * TODO: Replace the implementation with code for your list_photo type.
 */
class WeekCheckRecyclerViewAdapter(val flag: Int, private val mValues: List<WeekChekModel>, private val mListener: OnListFragmentInteractionListener?)
    : RecyclerAdapter<WeekChekModel>(R.layout.fragment_itemweekcheck, mValues) {
    override fun convert(helper: BaseViewHolder?, item: WeekChekModel?) {
        helper?.setText(R.id.project_name, item?.projectName) //项目名称
        helper?.setText(R.id.project_plan_week, "${item?.projectReportWeekly?.weeks}") //计划周次
        helper?.setText(R.id.project_plan_content, item?.planContext) //计划内容
        helper?.setText(R.id.project_plan_report_content, item?.reportContext) //报告内容
        helper?.setText(R.id.project_plan_writer, item?.createName) // 填报人
        helper?.setText(R.id.project_plan_write_time, item?.createTime) // 填报时间
        var result: String? = ""
        when (item?.reportStatus) {
            null -> result = "审批"
            2 -> result = "审批通过"
            3 -> result = "审批未通过"
        }
        helper?.setText(R.id.project_plan_ischeked, result) //是否审批
        helper?.setText(R.id.project_duty_units, item?.orgName) //责任单位
        helper?.setText(R.id.project_superversion_units, item?.projectName) // 监理单位
        helper?.setText(R.id.project_implement_units, item?.projectName) // 施工单位
        helper?.setVisible(R.id.project_superversion_units, false)
        helper?.setVisible(R.id.project_implement_units, false)
        helper?.itemView?.setOnClickListener { _ ->
            mListener?.onListFragmentInteraction(item!!, flag)
        }
    }


}